﻿


// 鼠标悬停提示
// 
// 主背景色（大区域）
// 通常使用明快的颜色（浅黄色等...）
if (typeof fcolor == 'undefined') { var fcolor = "#ffffff"; }

// Border的颜色和标题栏的颜色；
// 通常的颜色深（褐色，黑色等。）
if (typeof backcolor == 'undefined') { var backcolor = "#CDCDCD"; }

// 文字的颜色
// 通常是比较深的颜色；
if (typeof textcolor == 'undefined') { var textcolor = "#999900"; }

// 标题的颜色
// 通常是明快的颜色；
if (typeof capcolor == 'undefined') { var capcolor = "#FFFFFF"; }

// "Close"的颜色
// 通常是明快的颜色；
if (typeof closecolor == 'undefined') { var closecolor = "#9999FF"; }

// 弹出的窗口的宽度；
// 100-300 pixels 合适
if (typeof mdWidth == 'undefined') { var mdWidth = 200; }

// 弹出的窗口的高度；
if (typeof mdHeight == 'undefined') { var mdHeight = 100; }

// 边缘的宽度，象素。
// 1-3 pixels 合适
if (typeof border == 'undefined') { var border = "1"; }
// 以下是页面中使用的公共函数；
function DisplayToolInfoText(e, pid) {
    var obj = document.getElementById("txt" + pid);
    var str = "<div class=\"infotab\"><div class=\"tabtitle\"><span>当月重点工作</span></div><ul>" + obj.value + "</ul></div></div>";
    wsug(e, str);
}


function wsug(e, str) {
    var oThis = arguments.callee;
    if (!str) {
        if (oThis.sug.style != null)
            oThis.sug.style.visibility = 'hidden';
        document.onmousemove = null;
        return;
    }
    if (!oThis.sug) {
        var div = document.createElement('div'), css = 'top:0; left:0; position:absolute; z-index:100; visibility:hidden';
        div.style.cssText = css;
        div.setAttribute('style', css);
        var sug = document.createElement('div'), css = 'font:normal 12px/16px "宋体"; white-space:nowrap; position:absolute; left:0; top:0; z-index:10;  border:1px solid #c0c0c0';
        sug.style.cssText = css;
        sug.setAttribute('style', css);
        var dr = document.createElement('div'), css = 'position:absolute; top:3px; left:3px;  filter:alpha(opacity=50); opacity:0.5; z-index:9';
        dr.style.cssText = css;
        dr.setAttribute('style', css);
        var ifr = document.createElement('iframe'), css = 'position:absolute; left:0; top:0; z-index:8; filter:alpha(opacity=0); opacity:0';
        ifr.style.cssText = css;
        ifr.setAttribute('style', css);
        div.appendChild(ifr);
        div.appendChild(dr);
        div.appendChild(sug);
        div.sug = sug;
        document.body.appendChild(div);
        oThis.sug = div;
        oThis.dr = dr;
        oThis.ifr = ifr;
        div = dr = ifr = sug = null;
    }
    var e = e || window.event, obj = oThis.sug, dr = oThis.dr, ifr = oThis.ifr;

    //修改摘要格式
    str = "<TABLE WIDTH=" + mdWidth + " BORDER=0 CELLPADDING=" + border + " CELLSPACING=0 ><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\"" + fcolor
       + "\"><TR><TD style=\"text-align:left;\"><FONT FACE=\"宋体\" >" + str.replace(/<rn>/gi, "<br>\r\n") + "</FONT></TD></TR></TABLE></TD></TR></TABLE>";

    obj.sug.innerHTML = str;
    var w = obj.sug.offsetWidth, h = obj.sug.offsetHeight, dw = document.documentElement.clientWidth || document.body.clientWidth; dh = document.documentElement.clientHeight || document.body.clientHeight;
    var st = document.documentElement.scrollTop || document.body.scrollTop, sl = document.documentElement.scrollLeft || document.body.scrollLeft;
    var left = e.clientX + sl + 17 + w < dw + sl && e.clientX + sl + 15 || e.clientX + sl - 8 - w, top = e.clientY + st + 17;
    obj.style.left = left + 10 + 'px';
    obj.style.top = top + 10 + 'px';
    dr.style.width = w + 'px';
    dr.style.height = h + 'px';
    ifr.style.width = w + 3 + 'px';
    ifr.style.height = h + 3 + 'px';
    obj.style.visibility = 'visible';
    document.onmousemove = function (e) {
        var e = e || window.event, st = document.documentElement.scrollTop || document.body.scrollTop, sl = document.documentElement.scrollLeft || document.body.scrollLeft;
        var left = e.clientX + sl + 17 + w < dw + sl && e.clientX + sl + 15 || e.clientX + sl - 8 - w, top = e.clientY + st + 17 + h < dh + st && e.clientY + st + 17 || e.clientY + st - 5 - h;
        obj.style.left = left + 'px';
        obj.style.top = top + 'px';
    };
}


function getLeft(e) {
    var t = e.offsetLeft;
    while (e = e.offsetParent) {
        t += e.offsetLeft;
    }
    return t;
}
function getTop(e) {
    var t = e.offsetTop;
    while (e = e.offsetParent) {
        t += e.offsetTop;
    }
    return t;
}
function ShowMemo(obj, pid) {
    var objValue = document.getElementById("txt" + pid);
    var str = "<div class=\"infotab\"><div class=\"tabtitle\"><span>当月重点工作</span></div><ul>" + objValue.value + "</ul></div></div>";
    var box = document.getElementById("MajorWorkBox");
    box.innerHTML = str;
    ShowBox(obj, "MajorWorkBox");

}
function CloseMemo() {
    document.getElementById("MajorWorkBox").style.display = "none";
    document.onmousemove = null;
    //setTimeout(new function () { document.getElementById("ProcessBox").style.display = "none"; }, 100);
}
function ShowBox(obj, boxName) {

    var h = (boxName == "UserBox") ? 15 : 25;
    var box = document.getElementById(boxName);
    var left = getLeft(obj);
    box.style.display = "block";

    var top = getTop(obj);
    if (top > 400 && top > document.body.clientHeight - box.clientHeight - h) {
        top = top - box.clientHeight - h;
    }

    box.style.top = (top + h) + "px";

    if (left + box.offsetWidth > document.body.offsetWidth) {
        box.style.left = (left - box.offsetWidth) + "px";
    }
    else {
        box.style.left = (left + 60) + "px";
    }
}